package com.whmskj.xjlhsc.controller.vo;

import lombok.Builder;
import lombok.Data;
import org.springframework.http.HttpStatus;

import java.io.Serializable;

/**
 * @BelongsProject: XJLHSC
 * @BelongsPackage: com.whmskj.xjlhsc.controller.vo
 * @Author: lk
 * @CreateTime: 2025-06-10
 * @Description: TODO
 * @Version: 1.0
 */
@Data
@Builder
public class Result implements Serializable {

    private int code;
    private String msg;
    private Object data;
    private long timestamp;

    public static Result success(Object data) {
        return Result.builder().code(HttpStatus.OK.value()).msg("success").data(data).timestamp(System.currentTimeMillis()).build();
    }

    public static Result success() {
        return Result.builder().code(HttpStatus.OK.value()).msg("success").timestamp(System.currentTimeMillis()).build();
    }

    public static Result success(String msg) {
        return Result.builder().code(HttpStatus.OK.value()).msg(msg).timestamp(System.currentTimeMillis()).build();
    }

    public static Result error(int code, String msg) {
        return Result.builder().code(code).msg(msg).timestamp(System.currentTimeMillis()).build();
    }

    public static Result error(String msg) {
        return error(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg);
    }
}
